<template>
  <div class="container">
    <div class="tips-title">1.基础用法 <span class="tips-explain">从顶部出现，3 秒后自动消失</span></div>
    <el-button plain @click="open1">打开消息提示</el-button>
    <el-button plain @click="openCenter">文字居中</el-button>
    <el-button plain @click="openVn">创建Document Node方式</el-button>
    <el-button plain @click="openHTML">使用 HTML 片段</el-button>
    <div class="tips-title">2.不同状态<span class="tips-explain">「成功、警告、消息、错误」</span></div>
    <el-button plain @click="open2">成功</el-button>
    <el-button plain @click="open3">警告</el-button>
    <el-button plain @click="open1">消息</el-button>
    <el-button plain @click="open4">错误</el-button>
    <div class="tips-title">3.可关闭</div>
    <el-button plain @click="open5">成功</el-button>
    <el-button plain @click="open6">警告</el-button>
    <el-button plain @click="open7">消息</el-button>
    <el-button plain @click="open8">错误</el-button>
  </div>
</template>
<script>
  export default {
    name: 'no-message',
    data() {
      return {}
    },
    methods: {
      open1() {
        this.$message('这是一条消息提示');
      },
      open2() {
        this.$message({
          message: '恭喜你，这是一条成功消息',
          type: 'success'
        });
      },
      open3() {
        this.$message({
          message: '警告哦，这是一条警告消息',
          type: 'warning'
        });
      },
      open4() {
        this.$message.error('错了哦，这是一条错误消息');
      },
      open5() {
        this.$message({
          showClose: true,
          message: '这是一条消息提示'
        });
      },
      open6() {
        this.$message({
          showClose: true,
          message: '恭喜你，这是一条成功消息',
          type: 'success'
        });
      },
      open7() {
        this.$message({
          showClose: true,
          message: '警告哦，这是一条警告消息',
          type: 'warning'
        });
      },
      open8() {
        this.$message({
            showClose: true,
            message: '警告哦，这是一条警告消息',
            type: 'error'
        });
      },
      openCenter(){
        this.$message({
          message: '居中的文字',
          center: true
        });
      },
      openVn() {
        const h = this.$createElement;
        this.$message({
          message: h('p', null, [
            h('span', null, '内容可以是 '),
            h('i', { style: 'color: teal' }, 'VNode')
          ])
        });
      },
      openHTML() {
        this.$message({
          dangerouslyUseHTMLString: true,
          message: '<strong>这是 <i>HTML</i> 片段</strong>'
        });
      }
    }
  }
</script>
<style>
</style>

